package com.mosue.sample.sso.employee.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.client.OAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.*;

@Service
public class EmployeeService {

    @Autowired
    private OAuth2RestTemplate employeeRestTmplate;

    public Map<String, String> get_by_id(String id) {
        return new HashMap<>(0);
        //return employeeRestTmplate.getForObject("http://192.168.0.152:8082/resource/employee/" + id, Map.class);
    }


    public Map<String, String> get_by_id1(MultiValueMap<String, String> params) {
        return new HashMap<>(0);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entry = new HttpEntity(params, headers);
//
//        ResponseEntity<Map> response = employeeRestTmplate.postForEntity("http://192.168.0.152:8082/resource/employee/get_by_id", entry, Map.class);
//        return response.getBody();
    }

}
